@using System.Globalization
@using Microsoft.Extensions.Options
@inject IOptions<UiConfig> UiConfig

<!DOCTYPE html>
<html lang="en">
<head>
    <title>@this.ViewBag.Title</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    @Html.GenerateFavicon(Url.Content("~/favicon"))
    
    <!-- list:css -->
    <link rel="stylesheet" href="~/css/list.css">
    <!-- endinject -->
    @this.RenderSection("Styles", required: false)

    <!-- simplepage:js -->
    <script src="~/js/simplepage.js"></script>
    <!-- endinject -->
    <!-- list:js -->
    <script src="~/js/list.js"></script>
    <!-- endinject -->
    <!-- utils:js -->
    <script src="~/js/utils.js"></script>
    <!-- endinject -->    
    @this.RenderSection("Scripts", required: false)

    <script type="text/javascript">
        function FrameCheck() {
            if (top != self)
                top.location.replace(self.location.href);
        }

        $(function() {
            if (window.moment) {
                moment.locale('@CultureInfo.CurrentUICulture');

                $('time').each(function () {
                    var me = $(this);
                    var date = me.attr('datetime') || me.attr('time');
                    var momentDate = moment.utc(date).local().format('MMM DD, YYYY HH:mm');
                    me.text(momentDate);
                });
            }
        });
    </script>

</head>
<body onload="FrameCheck();">
    <div class="container-wb-list">
        <div class="header-wb-list">
            <header>

                <div class="questionnaire-logo">
                    <a class="logo" href="https://mysurvey.solutions/" target="_blank">
                        <img src="~/i/logo.png" alt="Survey Solutions" class="pull-left">
                        <span class="pull-left">Survey<br>Solutions</span>
                    </a>
                    @Html.ActionLink(QuestionnaireController.Designer, "Index", "QuestionnaireList", null, new { @class = "navbar-text" })
                </div>

                <ul class="nav nav-tabs">
                    <menu-item asp-controller="Questionnaire" asp-action="My">@QuestionnaireController.MyQuestionnaires</menu-item>
                    <menu-item asp-controller="Questionnaire" asp-action="Shared">@QuestionnaireController.SharedQuestionnaires</menu-item>
                    <menu-item asp-controller="Questionnaire" asp-action="Public">@QuestionnaireController.PublicQuestionnaires</menu-item>
                    <menu-item asp-controller="Classifications" asp-action="Index">@QuestionnaireController.Classifications</menu-item>
                    <menu-item asp-area="Admin" asp-page="/Users" asp-if="@User.IsAdmin()">@QuestionnaireController.ManageUsers</menu-item>
                    <menu-item asp-controller="Questionnaire" asp-action="Create" class="create">@QuestionnaireController.CreateNew</menu-item>
                </ul>
                <nav>
                    <a class="btn btn-default" target="_blank"
                       href="@UiConfig.Value.DesignerHelpUrl">@AccountResources.Help</a>
                    <a class="btn btn-default" href="@UiConfig.Value.ForumUrl" target="_blank">@AccountResources.Forum</a>
                    @if (User.IsAdmin())
                    {
                    <a class="btn btn-default"
                       asp-action="Index" asp-controller="ControlPanel" asp-area="Admin">
                        @QuestionnaireController.ControlPanel
                    </a>
                    }
                    <div class="btn-group">
                        <a class="btn btn-default">@string.Format(QuestionnaireController.Hello, User.Identity!.Name)</a>
                        <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            <span class="caret"></span>
                            <span class="sr-only"></span>
                        </a>
                        <ul class="dropdown-menu dropdown-menu-right">
                            <li>
                                <a asp-area="Identity" asp-page="/Account/Manage/Index">
                                    @AccountResources.ManageAccount
                                </a>
                            </li>
                            <li>
                                <a asp-area="Identity" asp-page="/Account/Manage/ChangePassword">
                                    @AccountResources.ChangePassword
                                </a>
                            </li>
                            <li>
                                <a asp-page="/Account/Logout" asp-area="Identity">
                                    @AccountResources.Logout
                                </a>
                            </li>
                        </ul>
                    </div>

                </nav>
            </header>
        </div>
        <section id="designer-list">
            @this.RenderBody()
        </section>
    </div>
    @this.RenderSection("Modal", required: false)
</body>
</html>
